package com.shop.bean;

import java.util.List;

public class Page<T> {

	private List<T> data;
	
	private int pageNum;
	
	private int pageSize;
	
	private int totalRows;
	
	private int totalPages;
	
	private boolean hasNext;
	
	private boolean hasPrev;

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public boolean isHasNext() {
		return hasNext;
	}

	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}

	public boolean isHasPrev() {
		return hasPrev;
	}

	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}

	public Page() {
		
	}

	public Page(List<T> data, int pageNum, int pageSize, int totalRows) {
		super();
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalRows = totalRows;
		this.totalPages = totalRows % pageSize == 0 ? (totalRows/pageSize):(totalRows/pageSize)+1;
		if(pageNum <= 1) {
			this.hasPrev = false;
		}else {
			this.hasPrev = true;
		}
		
		if(pageNum>=totalPages) {
			this.hasNext = false;
		}else {
			this.hasNext = true;
		}
		
	}
	
	
	
	
}
